package com.frogs.ucenter.v1.request;

import java.math.BigDecimal;
import java.text.DecimalFormat;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 用户充值记录创建请求参数类
 *
 * @author lijian
 * @version 2014年7月28日 - 下午2:41:34
 */
public class UserRechargeAddRequest extends Request {

	private Integer userId;
	
	private BigDecimal rechargeMoney;
	
	private String rechargeCard;
	
	private String rechargeFrom;
	
	public UserRechargeAddRequest() {
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.rechargeMoney = requestInfo.getBigDecimalParameter(ApiUrlParamEnum.rechargeMoney.getParamName());
		this.rechargeFrom = requestInfo.getParameter(ApiUrlParamEnum.rechargeFrom.getParamName(), "");
		this.rechargeCard = requestInfo.getParameter(ApiUrlParamEnum.rechargeCard.getParamName(), "");
		if (userId < 1) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		if (rechargeMoney == null || BigDecimal.valueOf(0).compareTo(rechargeMoney) == 0 || BigDecimal.valueOf(0).compareTo(rechargeMoney) == 1) {
			throw new RequestIllegalException("error rechargeMoney: " + rechargeMoney);
		}
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public BigDecimal getRechargeMoney() {
		return rechargeMoney;
	}

	public void setRechargeMoney(BigDecimal rechargeMoney) {
		this.rechargeMoney = rechargeMoney;
	}

	public String getRechargeCard() {
		return rechargeCard;
	}

	public void setRechargeCard(String rechargeCard) {
		this.rechargeCard = rechargeCard;
	}

	public String getRechargeFrom() {
		return rechargeFrom;
	}

	public void setRechargeFrom(String rechargeFrom) {
		this.rechargeFrom = rechargeFrom;
	}

}
